<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <title>PSP Time Log</title>
  </head>
  
  <body>
    <div class="nav">
      <span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Home</a></span>
      <span class="menuButton"><a class="home" href="${createLink(uri: '/pspData')}">PSP Data</a></span>
    </div>
    <div class="body">
		<h1>PSP Data List</h1>
		
	    <g:form action="show">
	      <div class="dialog">
	        <table>
	          <tbody>
	            <tr class="prop">
	              <td valign="top" class="name">Select Project :</td>
	              <td valign="top">            		  
					<g:select id="projectid" name="project.id" from="${Project.list()}" value="${project?.id}"
					    	  noSelection="${['null':' ']}" optionKey="id" optionValue="name">
					</g:select>              
	              </td>
	            </tr>
	            <tr class="prop">
	              <td valign="top" class="name">Select Team Member :</td>
	              <td valign="top">            		  
					<g:select id="userid" name="user.id" from="" value=""
					    	  noSelection="${['null':' ']}" optionKey="id" optionValue="userRealName">
					</g:select>              
	              </td>
	            </tr>
	            <tr class="prop">
	              <td valign="top" class="name">Select Task :</td>
	              <td valign="top">            		  
					<g:select id="taskid" name="task.id" from="" value=""
					    	  noSelection="${['null':' ']}" optionKey="id" optionValue="name">
					</g:select>              
	              </td>
	            </tr>
	            <!--
	            <tr class="prop">
	              <td valign="top" class="name">Select Sub Task :</td>
	              <td valign="top">            		  
					<g:select name="subtask.id" from="${SubTask.list()}" value="${subtask?.id}"
					    	  noSelection="${['null':' ']}" optionKey="id" optionValue="phaseName">
					</g:select>              
	              </td>
	            </tr>
	            -->
	          </tbody>
	        </table>
	      </div>	
	      <div class="buttons">
	        <span class="button"><input class="save" type="submit" value="Search" /></span>
	      </div>
	    </g:form>
		<br />
		<g:if test="${flash.message}">
			<div class="message">${flash.message}</div>
		</g:if>
		<g:if test="${pspList}">
		  <div class="list">
			<table>
			<thead>
			<tr>
				<th ROWSPAN=2>Project</th>
				<th ROWSPAN=2>Task</th>
				<th ROWSPAN=2>Sub Task</th>
				<g:each in="${projectTeams}" status="j" var="t">
					<th COLSPAN=2>${projectTeams[j][1]}</th>
				</g:each>
			</tr>
			<tr>
				<g:each in="${projectTeams}" status="j" var="t">
					<th>Start Date</th>
					<th Width="100">Actual Time</th>
				</g:each>
			</tr>
			</thead>
			<tbody>
			<g:each in="${pspList}" status="i" var="p">
					<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
						<td>${pspList[i][0]}</td>
						<td>${pspList[i][1]}</td>
						<td>${pspList[i][2]}</td>
						<g:each in="${projectTeams}" status="k" var="t">
							<td>${pspList[i][(k*2)+5]}</td>
							<td>${pspList[i][(k*2)+6]}</td>
						</g:each>						
					</tr>	
			</g:each>
			</tbody>
			</table>
		  </div>
		</g:if>
    </div>
    <script type="text/javascript">
    $(function(){
    	$('#projectid').change(function(){
    		$.get('getTeamList?projectId=' + $(this).val(), function(data) {  
    			$('#userid').html(data)
    		});
    		$.get('getTaskList?projectId=' + $(this).val(), function(data) {  
  				$('#taskid').html(data)
  			});
    	})
    })
    </script>
  </body>
</html>
